<?php
namespace App\Service\ApiXcx;

use App\Service\ApiQd\BaseService;
use Illuminate\Support\Facades\DB;

class CommonService extends BaseService
{
    //首页

    /**
     * 品牌
     * @return array
     */
    public function getAllConfig()
    {
//        $configs = getConfig();
//        return array('code' => 0, 'msg' => 'success', 'data' => $configs);
        $res = $this->dbwbConn($this->dbQdConfig)->get();
        if (!count($res)) {
            return $this->toback(-2, '没有记录');
        }
        $arys = [];
        foreach ($res as $v) {
            $v = (array) $v;
            $arys[$v['key']] = $v['value'];
        }
        return $this->toback(0, '', $arys);
    }

    /**
     * 品牌
     * @return array
     */
    public function getConfigByKey($key)
    {
//        $value = getConfig($key);
//        return array('code' => 0, 'msg' => 'success', 'data' => $value);
        $res = $this->dbwbConn($this->dbQdConfig)->where('key', $key)->value('value');
        if (!$res) {
            return $this->toback(-2, '没有记录');
        }
        return $this->toback(0, '', $res);
    }
}